import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author: hs
 * @Description:
 * @Date: Create in 15:55 2019/8/20
 */
public class MatcherTest {
    public static void main(String[] args) {
        numberCharChina();
        word();
    }
    private static void numberCharChina(){
        // 中文英文标点混合的字符串
        String str = "/*(薛聪，美得让人心碎 123。Oh, My God!)*/";

        // 将非数字、英文字母、汉字的部分替换为空后，就剩数字、英文字母、汉字了
        str = str.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5]", " ");

        // 输出为"薛聪美得让人心碎OhMyGod"
        System.out.println(str);
    }
    private static void word() {
        Pattern pattern = Pattern.compile("[a-zA-Z]+");
        Matcher matcher = pattern.matcher("哈哈");
        while (matcher.find()) {
            System.out.println(matcher.group());
            System.out.println(matcher.start());
            System.out.println(matcher.end());
            System.out.println("-----");
        }
    }
}
